{% extends "bases/base-nav.html" %}

{% block title %}
    Login
{% endblock %}

{% block head %}
{% endblock %}

{% block content %}
    <div class="container">
        <div class="row">
            <div class="col-md-offset-3 col-md-6">
                <form class="form-horizontal" id="login-tab">
                    {% csrf_token %}
                    <span id = 'logout-title'class="heading">用户登录</span>

                    <div class="form-group">
                        <input type="text" class="form-control" id="inputEmail3" placeholder="用户名" name="username">
                    </div>
                    <div class="form-group help">
                        <input type="password" class="form-control" id="inputPassword3" placeholder="密　码" name="pwd">
                    </div>
                    <div class="form-group">
                        <div class="main-checkbox">
                            <input type="checkbox" value="None" id="checkbox1" name="check"/>
                            <label for="checkbox1"></label>
                        </div>
                        <span class="text">Remember me</span>
                        <button id='login-btn' type="button" class="btn btn-default">登录</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script>
        $('#login-btn').click(function () {
            $.ajax({
                url:'/hosts/',
                type:'POST',
                data:$("#login-tab").serialize(),
                dataType:"json",
                success : function(data){
{#                    res=JSON.parse(data)#}
                    if(data.status){
                         window.location.href = "http://127.0.0.1:8000/hosts/index/";
                    }else{
                        $sapn=$("<span style='color: red'>");
                        $sapn.text(data.msg);
                        $("#logout-title").after($sapn);
                    }
                }
            });
        });
    </script>
{% endblock %}
